export function checkEmail (rule, value, callback) {
  const regEmail = /^\w+@\w+(\.\w+)+$/
  if (regEmail.test(value)) {
    // 合法邮箱
    callback()
  }
  // 邮箱不合法
  callback(new Error('邮箱格式错误'))
}

export function checkUsername (rule, value, callback) {
  if (value === '') {
    callback(new Error('请输入账号'))
  } else {
    callback()
  }
}

export function checkPhone (rule, value, callback) {
  const rex = /^1[34578]\d{9}$/
  if (rex.test(value)) {
    callback()
  }
  callback(new Error('手机格式错误'))
}

export function checkVerificationCode (rule, value, callback) {
  if (value === '') {
    callback(new Error('请输入验证码'))
  } else {
    callback()
  }
}

export function checkPassword (rule, value, callback) {
  if (value === '') {
    callback(new Error('请输入密码'))
  } else {
    callback()
  }
}
